#ifndef tool_commands_H
#define tool_commands_H

#include <QUndoCommand>
#include <QGraphicsItem>

class Page;

/**
 * A QUndoCommand that is used when a QGraphicsItem is added to a page.
 */
class AddGraphicItemCommand : public QUndoCommand
{

public:
    /**
     * Create a new AddGraphicItemCommand to push on a QUndoStack.
     * @param page The page the item is added to.
     * @param item The item that is added.
     */
    AddGraphicItemCommand(Page *page, QGraphicsItem *item);

    /**
     * Remove the item from the page.
     */
    virtual void undo();

    /**
     * Add it again.
     */
    virtual void redo();

private:
    /**
     * The page that the item is added to.
     */
    Page *page;

    /**
     * The item that gets added.
     */
    QGraphicsItem *item;
};

/**
 * UndoCommand for the eraser tool. Actually a reverse of the AddGraphicItemCommand.
 */
class EraserUndoCommand : public QUndoCommand
{
public:
    /**
     * Create a new EraserUndoCommand for the given item.
     * @param item The QGraphicsItem that will be removed.
     */
    EraserUndoCommand(QGraphicsItem *item);

    /**
     * Remove the item from the scene.
     */
    virtual void undo();

    /**
     * Add the item back to the parent where it was before.
     */
    virtual void redo();

private:
    /**
     * The QGraphicsItem to remove.
     */
    QGraphicsItem *m_item;

    /**
     * The parent item of the item to remove.
     * Taken from the item in the constructor.
     */
    QGraphicsItem *m_parent;
};

#endif
